package com.freewheelycheckin.server.models;

import javax.persistence.Id;
import javax.persistence.PrePersist;

public abstract class AbstractModel {
	@Id
    private String id;
    private Integer version = 0;
    
    public AbstractModel(){
    	this.id= java.util.UUID.randomUUID().toString();
    }
    /**
     * Auto-increment version # whenever persisted
     */
    @PrePersist
    void onPersist()
    {
            this.version++;
    }

    public String getId()
    {
            return id;
    }

    public void setId(String id)
    {
            this.id = id;
    }

    public Integer getVersion()
    {
            return version;
    }

    public void setVersion(Integer version)
    {
            this.version = version;
    }
}
